#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <math.h>
#include <pthread.h>

#include "dbfunc.h"

#define MODULE_NAME "SINGLE"

static char connect[20]="dbuser/oracle";

void Func();


int main()
{
    Func();

    exit(0);
}
                         

void Func()
{
    int result;
    emp_t emp;

    if((result=DbsConnect(connect))!=DB_OK)
    {
        printf("connect fail, sqlcode:%d\n", result); 
        goto FUNC_END;
    }

    emp.no=0;
    result=DbsEMP_UPD_Info(&emp);
    if(result!=DB_OK && result!=DB_NOTFOUND)
    {
        printf("database error, sqlcode:%d\n", result); 
        DbsRollback();
        goto FUNC_END;
    }
    if(result==DB_NOTFOUND)
    {
        printf("not found\n");
        goto FUNC_END;
    }
    DbsCommit();

    emp.no=0;
    result=DbsEMP_SEL_Info(&emp);
    if(result!=DB_OK && result!=DB_NOTFOUND)
    {
        printf("database error, sqlcode:%d\n", result); 
        goto FUNC_END;
    }
    if(result==DB_NOTFOUND)
    {
        printf("not found\n");
        goto FUNC_END;
    }
    printf("no:%012.0lf name:%s, update time:%s\n",
        emp.no, emp.name, emp.upd_ts);

  FUNC_END:
    DbsDisconn();
    return;
}
